<?php
require_once "Controller/clientBase.php";
require_once "Model/login.php";
require_once "Model/agenda.php";
require_once "Model/betalingen.php";
require_once "Repository/GebruikerRepository.php";
require_once "Repository/AfspraakRepository.php";
require_once "Repository/LeerlingRepository.php";
require_once "Repository/BetalingRepository.php";
require_once "Repository/PakketRepository.php";
        
class mainController
{
    private static $instance;
    private $client;
    private $login;
    private $agenda;
    private $betalingen;
    
    // Repositories:
    private $gebruikerRepository;
    private $afspraakRepository;
    private $leerlingRepository;
    private $betalingenRepository;
    private $pakketRepository;
    
    private function __construct()
    {
         session_start();
         $this->client = new clientBase();
         
         // Repo's:
         $this->gebruikerRepository = new GebruikerRepository($this->client);
         $this->afspraakRepository = new AfspraakRepository($this->client);
         $this->leerlingRepository = new LeerlingRepository($this->client);
         $this->betalingenRepository = new BetalingRepository($this->client);
         $this->pakketRepository = new PakketRepository($this->client);
         
         // Controls die juiste repo's meekrijgen:
         $this->login = new login($this->gebruikerRepository);
         $this->agenda = new agenda($this->afspraakRepository);
         $this->betalingen = new betalingen($this->pakketRepository, $this->leerlingRepository, $this->betalingenRepository);
    }
         
    //Instance van de klasse mainController
    public static function Instance()
    {
         if (self::$instance == null)
             self::$instance = new mainController();
            return self::$instance;
    }
    
     public function start()
     {
        if(isset($_GET['naam']) && isset($_GET['wachtwoord']))
        {
            $this->login->login($_GET['naam'], $_GET['wachtwoord']);
        }
        else if(isset($_GET['agenda'])) // Als er naar kalender wordt genavigeerd en er is een username
        {
             $this->agenda->GeefAgenda();
        }
        else if(isset($_GET['betalingen']))
        {
            $this->betalingen->Betalingen();
        }
        else if(isset($_GET['leerling']))
        {
            $this->betalingen->SpecifiekPersoon($_GET['leerling']);
        }
        else if(isset($_GET['betalingenVan']))
        {
            $this->betalingen->BetalingenSpecifiekPersoon($_GET['betalingenVan']);
        }
        else if(isset($_GET['pakketen']))
        {
            $this->betalingen->HaalAllePakketenOp();
        }
     }
}
?>